/*
 * game.h
 *
 * This has all the constants for the game
 *
 *  Created on: Dec 8, 2011
 *      Author: Jonathan Marokhovsky
 */

#ifndef GAME_H_
#define GAME_H_

#define MAP_WIDTH		46
#define MAP_HEIGHT		19
#define UPDATE_RATE		100000 // microseconds
#define BULLET_SPEED	1	// spaces per frame sent
#define MAX_NAME_LEN	20;
#define MAX_PLAYERS		10;
#define MAX_BULLETS		30; // three bullets per person for now

char theMap[] = 	   {	"______________________________________________\n"
							"______________________________________________\n" // these two lines are for the player names and scores
							"----------------------------------------------\n"
							"|               |           |                |\n"
							"|               |           |                |\n"
							"|               |           |                |\n"
							"|               |-- --|     |                |\n"
							"|                     |     |                |\n"
							"|                     |     |                |\n"
							"|                     |     |                |\n"
							"|                     |     |                |\n"
							"|                     |     |                |\n"
							"|                     |-----|                |\n"
							"|                                            |\n"
							"|                                            |\n"
							"|                                            |\n"
							"|                                            |\n"
							"----------------------------------------------\n"
							"     W, A, S, D to move, D-Pad to shoot       "};


typedef enum DIRECTION {
		NORTH,
		WEST,
		SOUTH,
		EAST
} Direction;

typedef struct pnt {
	int x;
	int y;
} Point;

/*
 * Info that must be contained in a player:
 * 		avatar
 * 		position (x,y)
 * 		name
 * 		IP address
 * 		port
 * 		score array (kill:death)
 */
//int maxNameLength = MAX_NAME_LEN;
typedef struct player_info {
	char avatar;
	Point position;
	char *ip;
	int port;
	int score[2];
	char *name; // this should be the max name length
} Player;

/*
 * Info that must be contained in a bullet:
 *		position (x,y)
 *		playerID that shot it
 */
typedef struct bull_info {
	Point position;
	int pID;
	Direction dir;

} Bullet;

/*
 * This function sends an updated map to all users
 */
int updateMap();

/*
 * This converts an (x,y) coordinate to line up with a 1d char[]
 */
int convertPoint(Point thePoint)
{
	int ret;
	int yMax = MAP_HEIGHT;
	int xMax = MAP_WIDTH;
	int y = thePoint.y;
	int x = thePoint.x;
	ret = (yMax - (y % (yMax + 1))) * (xMax + 1) + x;
	return ret;
}
#endif /* GAME_H_ */
